function compare(a = "", b = "") {
    let arr_a = a.replace("rc", "3").replace("beta", 2).replace("alpha", 1).split(".")
    let arr_b = b.replace("rc", "3").replace("beta", 2).replace("alpha", 1).split(".")
    for (let i = 0; i < arr_a.length && i < arr_b.length; i++) {
        if(arr_a[i]>arr_b[i]){
            return 1;
        }else if(arr_a[i]<arr_b[i]){
            return -1;
        }
    }
    return arr_a.length-arr_b.length
}
let result=compare("1.3.1.alpha.3","1.3.1.rc.2")
console.log(result);